Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@sewing-kit/hooks
Advanced tools
@sewing-kit/hooks
Interfaces and types for sewing-kit
hooks.
yarn add @sewing-kit/hooks --dev
Hooks, along with plugins, form the functional heart of sewing-kit
. Inspired by webpack's tapable library (guide), hooks provide a way for plugins to tap into sewing-kit
tasks in order to impart functionality to your workspace's dev setup.
The two types of hooks provided are a SeriesHook
and a WaterfallHook
. Both of these clases provide a hook
and run
method
import {SeriesHook} from '@sewing-kit/hooks';
const dog = {
breed: new SeriesHook<string>(),
};
dog.breed.hook((breed) => {
console.log('Received changes on the breed: ', breed);
});
dog.breed.run('American Bully');
// Received changes on the breed: American Bully
When run
is called on a SeriesHook
all the conainted hooks are resolved in sequential order. With a Waterfall
hook, the result of a hook is passed in as the argument for the next hook.
A lot of your use cases can probably covered by the hooks provided by core sewing-kit
, but you can always add your own hooks via plugins and a task's configureHooks
hook (adding hooks with hooks). For example, if you add, say, a plugin that introduces Jest to your workspace's testing setup, that plugin can also add a hook to let other plugins hook into its Jest configuration.
// Code from @sewing-kit/plugin-jest
hooks.configureHooks.hook(
addHooks<JestWorkspaceHooks>(() => ({
jestSetupEnv: new WaterfallHook(),
jestSetupTests: new WaterfallHook(),
jestWatchPlugins: new WaterfallHook(),
jestConfig: new WaterfallHook(),
jestFlags: new WaterfallHook(),
})),
);
Following from the previous example, another plugin further down might then do something like:
createWorkspaceTestPlugin('CustomPlugin', ({hooks}) => {
hooks.configure.hook((hooks) => {
hooks.jestSetupEnv.hook((oldJestSetupEnv) => {
// Do something to oldJestSetupEnv and return the new value
});
hooks.jestConfig.hook((oldJestConfig) => {
// Do something to oldJestConfig and return the new value
});
// ..etc
});
});
When you run sk test
, sewing-kit
will pick up your configs and plugins and run Jest with your specified option/config values.
FAQs
Hook interfaces for sewing-kit-next
We found that @sewing-kit/hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.